#include <iostream>
#include <cstdio>
#include <cstdarg>

void myprintf(size_t num, ...)
{
    va_list ap;
    va_start(ap, num);

    for (int i = 0; i < num; i++)
    {
        char ch = va_arg(ap, int);
        std::cout << ch;
    }
    std::cout << std::endl;

    va_end(ap);
}

void myprintf(const char *fmt, ...)
{
    va_list ap;
    va_start(ap, fmt);

    char str[64] = {0};
    int len = vsnprintf(str, sizeof(str), fmt, ap);
    str[len] = 0;
    std::cout << str << std::endl;

    va_end(ap);
}

template <class T, class... Args>
void show(T val, Args &&...args)
{
    std::cout << val;
}

template <class... Args>
void myprintfcpp(Args &&...args)
{
    show(std::forward<Args>(args)...);
}

int main()
{
    myprintf(3, 'L', 'O', 'L');
    myprintf("%s %d", "你好", 2024);

    return 0;
}